<?php

namespace App\Beans;

use App\Models\System\SysDeptModel;
use App\Models\System\SysMenuModel;

/**
 * Treeselect树结构实体类
 *
 * @date 2023-09-13
 */
class TreeSelect {

    
    /** 节点ID */
    private int $id;

    /** 节点名称 */
    private string $label;

    /** 子节点 TreeSelect[] */
    private array $children;


    public function __construct(null|SysDeptModel|SysMenuModel $ob=null) {
        if ($ob == null) {
        } else if ($ob instanceof SysDeptModel) {
            $this->id = $ob->dept_id;
            $this->label = $ob->dept_name;
            $this->children = $ob->children;
        } else if ($ob instanceof SysMenuModel) {
            $this->id = $ob->menu_id;
            $this->label = $ob->menu_name;
            $this->children = $ob->children;
        }
    }

    public function getId(): int { return $this->id; }
    public function setId(int $id): TreeSelect { $this->id = $id; return $this; }
    public function getLabel(): string { return $this->label; }
    public function setLabel(string $label): TreeSelect { $this->label = $label; return $this; }
    public function getChildren(): array { return $this->children; }
    public function setChildren(array $children): TreeSelect { $this->children = $children; return $this; }

}